#ifndef sonar_h
#define sonar_h

/************************************************************************************************* 

	Name: SONAR_H
	Autor: JA&AP
	
	Contains: 
				Header File containing all the functions related to the Sonar Sensors hardware.
				
				
**************************************************************************************************/

#if NXBOT_SONAR_COUNT == 3
#define SONAR_45N 0
#define SONAR_0 	1
#define SONAR_45P 2
#elif NXBOT_SONAR_COUNT == 5
#define SONAR_80N 0
#define SONAR_45N 1
#define SONAR_0 	2
#define SONAR_45P 3
#define SONAR_80P 4
#elif NXBOT_SONAR_COUNT == 6
#define SONAR_80N 0
#define SONAR_45N 1
#define SONAR_10N 2
#define SONAR_10P 3
#define SONAR_45P 4
#define SONAR_80P 5
#elif NXBOT_SONAR_COUNT == 8
#define SONAR_80N 0
#define SONAR_60N 1
#define SONAR_30N 2
#define SONAR_10N 3
#define SONAR_10P 4
#define SONAR_30N 5
#define SONAR_60P 6
#define SONAR_80P 7
#endif

#define SONAR_STATE0_REQ 0
#define SONAR_STATE1_1B 1
#define SONAR_STATE2_2B 2

#define SONAR_READ_READY 0
#define SONAR_READ_NOT_READY 1




void sonar_init(void );
void sonar_cleanBuffer(void);
void sonar_write(unsigned char sonarNum);
unsigned char sonar_read(unsigned char sonarNum, unsigned int *val, char newState);
#endif
